<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
    <title>学生列表</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            background-color: #f4f4f4;
            margin: 0;
            padding: 20px;
        }
        h1 {
            color: #336699;
            text-align: center;
        }
        table {
            width: 100%;
            border-collapse: collapse;
            margin-top: 20px;
        }
        th, td {
            padding: 8px;
            text-align: left;
            border: 1px solid #ddd;
        }
        th {
            background-color: #f2f2f2;
        }
        tr:nth-child(even) {
            background-color: #f9f9f9;
        }
        tr:hover {
            background-color: #ddd;
        }
        input[type="text"] {
            width: 200px;
            padding: 8px;
            margin: 5px 0;
            box-sizing: border-box;
            border: 1px solid #ccc;
            border-radius: 4px;
        }
        input[type="submit"] {
            padding: 8px 16px;
            background-color: #4CAF50;
            color: white;
            border: none;
            border-radius: 4px;
            cursor: pointer;
        }
        input[type="submit"]:hover {
            background-color: #45a049;
        }
    </style>
</head>
<body>
<form action="StudentServlet">
    <input type="text" name="sName" placeholder="请输入姓名">
    <input type="submit" value="查询">
</form>
<h1>Student</h1>
<table border="1">
    <tr>
        <th>编号</th>
        <th>姓名</th>
        <th>生日</th>
        <th>性别</th>
        <th>操作</th>
    </tr>
    <c:forEach var="student" items="${students}">
        <tr>
            <td>${student.sId}</td>
            <td>${student.sName}</td>
            <td>${student.birth}</td>
            <td>${student.gender}</td>
            <td>
                <a href="getStudentById?sId=${student.sId}">修改</a>
                <a href="javascript:del(${student.sId})">删除</a>
            </td>
        </tr>
    </c:forEach>
    <script>
        function del(id) {
            if (confirm("确定删除吗？")) {
                location.href = "deleteById?sId=" + id;
            }
        }
    </script>
</table>
</body>
</html>

